import numpy as np
import matplotlib.pyplot as plt

def local_lyapunov_exponent(X, d, r):
    """
    Calculate the local Lyapunov exponent of a trajectory X using the method of Rosenstein et al.
    
    Parameters:
    X (numpy.ndarray): The trajectory of shape (n, m), where n is the number of time steps and m is the dimensionality of the system.
    d (int): The number of nearest neighbors to use in the calculation.
    r (float): The radius of the neighborhood to use in the calculation.
    
    Returns:
    numpy.ndarray: The local Lyapunov exponent of each point in the trajectory.
    """
    n, m = X.shape
    L = np.zeros(n)
    for i in range(n):
        # Find the d nearest neighbors of X[i]
        distances = np.sqrt(np.sum((X - X[i])**2, axis=1))
        neighbors = np.argsort(distances)[1:d+1]
        
        # Calculate the local Lyapunov exponent
        w = np.zeros(d)
        for j in range(d):
            # Find the neighbors of X[neighbors[j]] within radius r
            distances = np.sqrt(np.sum((X - X[neighbors[j]])**2, axis=1))
            neighbors_r = np.where(distances < r)[0]
            
            # Calculate the average distance between X[neighbors[j]] and its neighbors within radius r
            if len(neighbors_r) > 0:
                w[j] = np.mean(distances[neighbors_r])
        
        if np.sum(w) > 0:
            L[i] = np.mean(np.log(np.abs(w)))
    
    return L

# Example usage
X = np.random.randn(10000, 3)
L = local_lyapunov_exponent(X, d=10, r=0.1)
plt.plot(L)
plt.show()